package com.mgface.framework.springboot.web;

import java.util.Enumeration;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.mgface.framework.entity.RandomEntity;

@RestController
public class RandomController {
	private final static Logger log = LogManager.getLogger(RandomController.class);	
	@Autowired
	private RandomEntity randomEntity;

	@RequestMapping("/print")
	public String print(HttpServletRequest request, HttpServletResponse response) {
		// String uri = request.getRequestURI();
		Enumeration<String> enums = request.getHeaderNames();
		while (enums.hasMoreElements()) {
			String element = enums.nextElement();
			String value = request.getHeader(element);
			log.info("key:{},value:{}", element, value);
		}
		log.info("是否开发模式:{}", randomEntity.getDevModel());
		log.info("随机值a:{},随机值b:{},随机值c:{},随机值d:{},随机值e:{}", randomEntity.getSecret(), randomEntity.getNumber(),
				randomEntity.getBignumber(), randomEntity.getLessthanten(), randomEntity.getInrange());
		return "success";
	}
}
